package tw.rescue.web;

import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import ognl.OgnlRuntime;

import org.apache.log4j.PropertyConfigurator;

public class WebContextListener implements ServletContextListener {

	public static Long startupTime = null;
	private static final Logger logger = Logger.getLogger(WebContextListener.class.getName());
			
	public void contextInitialized(ServletContextEvent event) {
		OgnlRuntime.setSecurityManager(null); //要在gae使用struts2第一步就是要處理ognl
		startupTime = System.currentTimeMillis();
		// Locale.setDefault(Locale.TAIWAN); // GAE 不允許
		logger.log(Level.INFO, "Loading request occurred.");
		URL configURL = getClass().getResource("/log4j.properties"); 
		if (configURL!=null) {
			PropertyConfigurator.configure(configURL);
			logger.log(Level.INFO, "log4j configuration completed");
		}
	}

	public void contextDestroyed(ServletContextEvent event) {
	}
}
